package com.ruoyi.labour.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.labour.domain.vo.PageVo;
import com.ruoyi.labour.domain.vo.UpdateSlideshowVo;
import com.ruoyi.labour.domain.vo.UploadSlideshowVo;
import com.ruoyi.labour.service.SlideshowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: SlideshowController
 * @Description:
 * @Author: Awen
 * @Date: 2023/5/13 14:56
 */
@RestController
@RequestMapping("slideshow")
@Api(tags = "轮播图管理")
public class SlideshowController {

    @Autowired
    private SlideshowService slideshowService;

    /**
     * 添加轮播图
     * @param uploadSlideshowVo
     * @return
     */
    @ApiOperation("保存轮播图信息")
    @PostMapping("addSlideshow")
    public R addSlideshow(@RequestBody UploadSlideshowVo uploadSlideshowVo){
        return slideshowService.addSlideshow(uploadSlideshowVo);
    }

    /**
     * 查询轮播图文件信息
     * @param pageVo
     * @return
     */
    @ApiOperation("查询轮播图文件信息")
    @PostMapping("/selectSlideshow")
    public R selectSlideshow(@RequestBody PageVo pageVo){
        return slideshowService.selectSlideshow(pageVo);
    }


    /**
     * 修改轮播图
     * @param updateSlideshowVo
     * @return
     */
    @ApiOperation("修改轮播图")
    @PostMapping("/updateSlideshow")
    public R updateSlideshow(@RequestBody UpdateSlideshowVo updateSlideshowVo){
        return slideshowService.updateSlideshow(updateSlideshowVo);
    }

    /**
     * 删除轮播图
     * @param id
     * @return
     */
    @ApiOperation("删除轮播图")
    @GetMapping("/updateSlideshow/{id}")
    public R deleteSlideshow(@PathVariable("id") int id){
        return slideshowService.deleteSlideshow(id);
    }


}
